package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import com.evacipated.cardcrawl.mod.stslib.actions.common.AllEnemyApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.StrengthPower;

public class Kitan extends BaseCustomCard {
    private static final String RAW_ID = Kitan.class.getSimpleName();
    public static final String GAME_ID = RAW_ID;

    public Kitan() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        addToBot(new AllEnemyApplyPowerAction(player, -magicNumber, m -> new StrengthPower(m, -magicNumber)));
        addToBot(new AllEnemyApplyPowerAction(player, magicNumber, m ->
                new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, m, magicNumber) {
                    @Override
                    public void updateDescription() {
                        description = String.format(descriptions[0], amount);
                    }

                    @Override
                    public int onAttacked(DamageInfo info, int damageAmount) {
                        if (info.type == DamageInfo.DamageType.NORMAL) {
                            flash();
                            Util.applyPower(m, m, new StrengthPower(m, magicNumber));
                            addToBot(new RemoveSpecificPowerAction(m, m, this));
                        }
                        return damageAmount;
                    }
                }));
    }
}
